﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class rename_table_ProductNamespace : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainTopicDict_MainNamespaceDict_NamespaceDictId",
                table: "MainTopicDict");

            migrationBuilder.DropTable(
                name: "MainNamespaceDict");

            migrationBuilder.CreateTable(
                name: "MainProductNamespace",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    NamespaceCode = table.Column<string>(type: "text", nullable: false),
                    NamespaceName = table.Column<string>(type: "text", nullable: false),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainProductNamespace", x => x.Id);
                });

            migrationBuilder.AddForeignKey(
                name: "FK_MainTopicDict_MainProductNamespace_NamespaceDictId",
                table: "MainTopicDict",
                column: "NamespaceDictId",
                principalTable: "MainProductNamespace",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_MainTopicDict_MainProductNamespace_NamespaceDictId",
                table: "MainTopicDict");

            migrationBuilder.DropTable(
                name: "MainProductNamespace");

            migrationBuilder.CreateTable(
                name: "MainNamespaceDict",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    DefaultFlag = table.Column<bool>(type: "boolean", nullable: false),
                    Exp = table.Column<string>(type: "text", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true),
                    NamespaceCode = table.Column<string>(type: "text", nullable: false),
                    NamespaceName = table.Column<string>(type: "text", nullable: false),
                    Srtno = table.Column<int>(type: "integer", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainNamespaceDict", x => x.Id);
                });

            migrationBuilder.AddForeignKey(
                name: "FK_MainTopicDict_MainNamespaceDict_NamespaceDictId",
                table: "MainTopicDict",
                column: "NamespaceDictId",
                principalTable: "MainNamespaceDict",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
    }
}
